$(function () {
  $('#regist1').on('click', function () {
    let username = $('#username').val(),
      password = $('#password').val();
    // console.log(username);
    // console.log(password);
    $.ajax({
      type: 'post',
      url: '../../interface/reg.php',
      data: {
        username: username,
        password: password,
      },
      // dataType: "dataType",
      success: function (res) {
        console.log(res);
        if (res == 'success') {
          alert('注册成功');
          location.href = './index.html';
        } else if (res == 'exist') {
          $('.login-fail').text('用户名已存在');
        } else {
          $('.login-fail').text('请输入用户名或密码');
        }
      },
    });
  });
});
